added comment and tidying up