all tests passing, code tidied