rewrite to make it a module