fixed corner cases crashes