Fixed nil pointer error