minor refactor and fix Co-authored-by: deltanedas <@deltanedas:kde.org> (cherry picked from commit b453b9414810ed927228eb563c6b1c491532c5e3)