contract logic