start to despaghettizing code