completed the function check_rep_subgrid(grid); still needs work like refactoring out the repetition but it works