add exception handle and javadoc