refactoring of https://code.google.com/p/javasimon/issues/detail?id=129