adding exercise 18
fixed a memory leak