Fixed timestamp reference error introduced by refactoring global to local variables