Upgrade for codes input
Tidy up