tidied up pin initialisation