Updated to move more code into own routines. Added Low Pass filtering