Rewrite started

How did this spaghetti code work