replaced if-else construct by function calls in getNearestPortal