refactored a lot, more outputs