split up for better testability