1. Adding JSON lib and its dependencies
2. Correcting the logic flow