Refactor code part1