model(): generate code for filter function, also fixes closure issue