fix nil pointer error