runs correctly when debug mode is ON