some small refactors for clarity