Factored some more code