Refactoring for timestamps and modularization