rewrite run() correctly, pull steps out of __main__ so they can be called from run method