Fix bug, clean code