code tidy

tidied up the code and added new cases for individual pins