Refactor check for system memory into separate function