finished first version
time calculation