Neaten up the code a bit