moved to a key derivation function
added comments