refactoring statement rewrites and adding warnings