now uses exists function to check hash instead of loop and regex