tidy up and support for key as arg