partial work on portal algorithms