tided up scripts location and error checking