Removed duplicated code and exported in a module