fixed some variable names and added noise detection