added delete graphic function; some refactor