Fix bug when using less than three images