using time diff to avoid paint too frequently