tidy up code, and interface, shorten code significantly