code for refactor