fixed sql-prepare in some places