Refactor code in to two classes