working but needs refinement