Javascript undefined bug fix.