needs to refactor code to work with rspec