function called two times