getting script to work right