Rewritten the Controller run() function to fix #3 and #5