time function fixed and cache added