implemnting portal logic