minor code reorganistation