rewrite the set time function