Changing icon image and refractoring the code.