Refactor and cleand code