added error check for uninitialized memory locations