This is the fix I mentioned. Somehow using a switch seems to interrupt with the actual location check. thus jumping to default and skipping the check for portaltype.