updating script to be more dynamic