reorganizing the code