made encoding methods more efficient