cleaned up the code and added a build script