start of refactoring of plsql code