Modularized functions

This makes the function more portable around.

It also avoids an extra call as it as at the
global scope.