Slightly updated output, cleaner logic