add time handling (thanks to @deadcat64)