Divided up code fore more testability