simplified code, changed demo