Fix and added time function