fix: Remove unused code and avoid nested if