should be a double pointer

also freed heap memory