remove extra loop, variable initialization