refactored the whole project