simplified code

replace functions