some enhancements for error checking