Redoing code in supplement
simplified part of supplement code