this looks messy. Can you refactor this?