model fix and some sqls