Make update method more general