Updated grid_id implementation, now matches GED stored procedure to_grid_id9