add entry image handle logic and optimize some code