Refactored memory access