The use of loops in the code leads to poor performance for large surveys. Performance can be improved using the map function throughout the code.