cleaned up image code