Make code more generic