refactor the coee