refactored drawing to minimize canvas painting