minor refactor. Add comments