reducing repeated code