Repairing error in javascript.