tidied some code