Update update()

use Random r instead plus cleaned up duplicate code