restructured analysis slightly and added intermediate values