finalizing code and output