New modularized function.