Changed all implementations into modules
refactoring the changes and added additional functions.