refactored whole project