lastInsertId functionality fix