fixed nil pointer error