a nicer approach to solving #495