refactoring and commenting stuff