Added debug mode for testing