Refacto and improvments