version 1.2, source code rearranged