tidied code up