refactoried all the stuff -- V2