Refactor in session.rb