same idea as spiralMatrix though simpler