Reorganizing the code