Improve main code