refactor and basic completion