starting to refactor the code.