setup scope tracking and state tracking