cleaned up updating code