modify scoping + add some perfs optimisations to selectors