Small fix for finding #endif
Added range support