moved reset data into function