fixed error when accessing a non-existing element