some code tidying