Last version with malloc