my first handwritten-from-scratch code, all my own.