all sql statements written: need debugging