fixed bug calculating pins, now it should be working (for real this time)