refactor bugs