Fix issue after update, rewrite code on edit to be more correct