faster solution