I guess you copied my comment but ended up implementing it differently