refactored canvas context