removed empt lines'
added try-catch block