fixing loop iteration and appname comparison