warning! bug: trying to shrink the code
fixed bug, added function to get earliest and latest times
"earliest time"-function currently not working