re-organize source code