Single page javascript error fix