try to make things clearer by refactoring into seperate classes