cleaned duplicate code and added max execution time of script