moved card image logic to main.rb and other code refactoring