draft of run function finished