refactor first image retrieval and fix bugs
delete useless code block