cleaning up code for distribution