draw to update

move main function from draw to update