fixed CS, added exception check