adapted for correctly working on amd and cjs