Not sure what is the point to use yield to return encoding, thus it will simplify the whole function. Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>