Fixed the new algorithim - was previously throwing errors every now and again