remove unnecessary comments and format
fixed some recursion issues when retrying other keys
resolve conflict