able to get commands to work once, but freeing memory still a problem