fixed out of range error
remove needless :while
fixed wrong command pattern
cache for speed
update py