Wrote a real algorithm or something