fixed error in smallest number calculation