tidy the code a bit