check length of key first