Refactor code related to parameterized queries