more refactoring, created memory unit