refactor to OO, sep of concerns etc