add debugging toggle and refactor requirement check