Trying to restructure the script