removed some repetitive code with toStrin.call into a function converter
wrapped everything in an immediate function