about to refactor again
removed a bunch of bugs