Added checks for null result arrays