code refactor part 1