improving module factory