script fixed but still only half-working