some basic refactoring done, still a bit to go before I can start
implmenting anything more complicated