simplify memory plugin code