despaghettizing code