added attachRunWait function