Function to check the signature

working, needs few tweaks.