adding java exception handling