added secure mode logics