debugging memory and conditional errors