Fixed setScope check
Code clean