moved reconstruct output after last if else