Refactored the code
Fixed add osd issue