update code to make more sense