Can you think about a way to refactor this? Is very verbose and I'm sure there's a cleaner way to do it