added script to process results, cleaned up code