refactor(utils.go): ♻ improve error handling and code readability
This MR:
- removes nolint remarks
- improves error handling
- renames variables to a more meaningful name and
- reduces the complexity of several functions