moved memory check