Bug fixing: checking for empty array