added pin read function