significantly refactored the most of the code base