worked on making the code neater