found some bugs scanning the code