nearly complete the lybrith algorithm, but would be broken sometimes