reworking image functions