move signature logic into a  library