added pin generation function