refactor submit image method