added freeMem() for debugging