Why you are doing this again yourself?
You know there can be nested aliases and such!

pfSense development has already gone once for implementing this.
I do not understand this trend.

Again you are using gehostbyname here which should not be done until another process is defined for packages that does not break the normal filter reload.