refactored to reflect ruby styleguide
changed tabs to spaces