extract timestamp more correctly