Added Mark's suggestions for better efficiency