refactor the code to draw the related entity canvas