Program functional, needs optimization for better efficiency.