moved common pieces of code to helper module for transformer.rb