fixed if logic and renamed jsonObj