removed extra undefined check