Move to ruby

This method needs rewriting, it makes no sense to assign something to ``current_state`` X times here :<