This would probably be cleaner if it was not defined inline