Fix bug in secret determination