added signature calculation; split code