added nil checks in ui