created run functions for threading