added multiple state usage with precedence