Added rate logic and return json