implemented drawing function