Refactored morph code to be smaller