Code has been reorganized and optimized