removing repeated code