Fixing scripts for effeciency