fixed JS error with null element