Fast solution implemented