ACTN-18 - jin - changed the parameter input to const so that it doesn't mutate it. Also, cleaned up code