Refactoring. Slight performance improvement.