cleanup - fixed "headers already sent" issue