update logic and fix json