add rudimentary memory guard