Add code validation and fix update bug