Fixed algorithm passes 100%!