cleanup/eslint and refactor some functions to make use of reduce/filter/forEach