added classcast try catch block