slowly trying to incorporate changes from yus code