roughly working from end to end. needing extreme refact