runHandler was getting a bit big, split it out to a separate function