Refactor the drawing function to a directive