tidied code layout