Eliminated subscript out of bounds errors