rewrote parts of defs