Added error checking for location