Improve performance by removing loops while processing data