remove output, and refactor