code refactor to use function for image fade-in