Made solution more efficient