Modified run script to work with threading