This was really complicated