fixed a few edge cases