refactored how images are randomized