Some refactorign