new code structure
reorganized code