eilidh algorithm for more golfy code