replacing magic num with val