Simplified the code by removing some col/row mutation.