updated to work from nib as well