Reduce complexity of run function