now passing tests, however refactor needed to use less hacks