Refactor code into 1 class