refactoring for prepared statements