Javascript runtime error resolved