updated from Ian's changes