This line here: take out the above if statement and make it check conditon instead, you dont need to check the response of getDvCriteria, it should be array() at all times