implement lexical scope
correct priority of types