re-factorize code, implement capture of small images