save modified code

started on memory management