Moved method out to make other method shorter and to make it more testable