refactor to deal with module caching issue