refactored the pins controller