using some const references for read-only values
using a for-each loop to increase readibility