small change in menu method to exit if str is nil