added javascript error detection