Take inside functions outside and upgrade
All upgraded, everything should works, need to change little tests beacuse of changes inside to outside functions