updated script for effeciency