Changed conditions from calculate_fg

Changed conditions to go through whole inner cells only for boundary
cells.