redone more cleanly