Added memory check