Modified function to find json object in list