refactoring, espruino version prepared