code refactoring of morph