Added basic error handling in mapgrid