several minor adjustment for sake of code clarity and ease of maintenance