refactor hash constraint