fix substring error being outside of string, simplify comparison operations, start refactoring string search operations