Much faster solution