limit scope, and check for error