Refactored for a faster and simpler way