Add automated hash

Simple trick to make the code smaller, and more efficient hopefully.