some broken code and some refactoring