first working version of the code. still need to update README.