moved all peripheral wrapping logic over to here