cleaned up update func
cleaned and organized things