changed code to JOptionPane