Another attempt at fixing script