Tidied code a bit