Fix problems on mem function