Use the result from rtrim()
Remove unnecessary variable check
Rename variable