tried to make script more generic