created module concept and major refactoring to seperate conerns