added draw-detecting functionality