We have this legacy image viewer component in our project that's working fine but it's source is a real mess. I have to add a new feature to this component so that people can add annotation to images using a light pen which is not a complicated task per se but could be a nightmare dealing with our existing code.
I'm really confused right now I don't know where should I start . do I have to refactor the existing code?if not what else can I do?
So here's my question: What could be the best (less painful) approach dealing with such situations?