Moved mem function to utils