fixed divide and added try catch