sloppy but kind of working