Reduce code duplication in ofx.js