added outer scope check