Added algorithm to fill out grid