Finished Encoding Function