fixed nil pointer error on field access of nil