ENH: Added error checking