added pin checking