added logic to limit log size