Fixed nil pointer error.