Made the wrap function behave more like my coding style and added a linux version