An improved model for the formation times of dark matter haloes