updated layout, added comments to logic