added optional assertion for speedup