Seperate pin mode logic to seperate function