Tidying some code up