Added debug mode for testing purposes