refactoring
made assertion more clear
made cursor redraw more reliable