refactor code part 1