added pseudo-code for refactoring

Merge this. It has valuable pseudocode.