Made program more efficient

Made use of basic pointers to make program more efficient