change each statement to be more memory effecient