refactor, still a bit to go..