added library and tidy up