using croak for error handling