REV: some code optimization