little optimization and I removed an unsed variable