finished pseudo code for measure