whole thing working now, just needs refinement