Trouble shooting this code.  Made some general changes.  But the two main changes were removing a line that got rid of zeros and correcting the parts that fill in the trailing NA data with zeros.