changed datetime and reformed code