Some code redesign aka DRY ;)