added map validity check