rewrote code in an attempt to fix it