fixing mistake on and quick refactor