cleaned up code based on comments provided by ageorge
removed unused variable