updated to proper code syntax and added rspec tests