Corrected up/down logic

Up/down commands weren't checking for upper/lower bounds of array, fixed
that.