refactor to use .toRight