Repaired javascript bug