Refactorig + more nice loging