code tidied