Added logic to Sean's scoping