Moved next module code to its own function.
Moved previous module code to its own function.