Removed unused function.
Corrected important bug: for each image that is read one would be skipped unintentionally