reviewed and cleaned up script