rewrite complete and functional, on to unit tests...