modified to comply with java6