Moved pin state to database