refactored image and drawing into a widget