total rewrite, makes more sense now