compute the stages