fixed bugs not handling multiple fragments in one file