Use max instead of if to get biggest timestamp