Working code, but much more to be desired...