Made script more generic