Refactored the module to fit with Gateway Version 4.0