adding test cases
made the code more structered