minor fix for compatibility
separate central logic from main function so can be called externally via run(Param* param)