solution for p3
time function