add Scopes func and rearrange a bit