Updated code with JavaDoc