image storing logic still wrong