Cleaned up code + added length for P- and T-wave