Added debug mode as an argument