corrected spelling and removed some unused code as suggested