polishing the code to pass the tests