Made script more versatile