Modularize common functions
Modularize common functions