Can you add a comment here what this long `else if` is checking and doing?