Aidoc interview question

Refactor code to improve readability, simplify and enhance maintainability