fixed an issue in the annotation handling and simplified the code