Refactoring, add some functions

add some new utility functions
refactor retain-methods to where
refactor transform-methods to map