refactor C code into io and node module