Simplify code

This also avoids creating a global function in addition to exporting.