A little optimization/refactor