added helper function for error