ime: free allocated variables before return statement