Rewrote more cleanly