simplifying code and tidying