UDF only returned constant values in WHERE statments. This was fixed by properly setting const_item = 0