Refactor code for multiple module loading