Implemented deallocate function