fixed a few problems with my script