updated graphics code (close to submission of draft 2)