Added inverting, Bugfix (only bottom thresh working); TODO: optomize