fixing bugs in row shift logic