refactor the code  Part 1