more DRY, more explicit integer casting