bug; substring counts from 1
confusing attempt at boolean functions fixed; thanks Deyan