added set W, cleaned id code