Fixing time_in function