optimizing sigma computation. adding clarifying comments.