adding already made from thesis code, generic code for memories to be added later