Just wasted far too much time on a problem with a ridiculously easy solution. So annoyed at myself! Oh well, TGIF!