correct minus sign, put codes into cpp files