tidy up code for #282