Adding layout.erb and removing duplicate code