refactoring and cleanup
added pseudo-test