refractored how my algorithm worked. See readme