added generic checking function
fixed merge conflict