made script more generalized