added free because of malloc used