code refine for contract code