moved encode and post into the main lib