updating script. needs debugging