refactor code again