implement distribution code