giant rewrite because my old api sucked