This is very difficult to read code and there is no need to get the property every time. When the MapService is constructed, pull out everything that is needed from the groupproperties and then reuse it. It will not only be faster, but it will be a lot easier to read.