Added logic to send data to database on time up or on completion.