Add for-in loop to remove repeated coded and add for further configurability