gettickets function does not insert tickets repeated in the database