breaking up large code block to give more explanation