tidied up code for id pending work.