implemented HSMLayer (now needs debugging)