Fixed issues with null and empty array