Added two ways to perform pinning and some rewritten