Some bug and added code to list all discovered applications in the end