Fixing bug in portals' logic