replace the code with a working function