fixed warniung and freed memeory