reorganized source code