fixing outputs before redirects