polygon drawing not always working