removing empty lines and tidying code