almost there,yet another code refactor