Added error checking helper