refactor overlay showing code