Tidying the code up