Changed from module to function

Applied `return` fix (@celtric)
Changed from static module to function