Remove unnecessary use of loops