Bug fix: replace echo with exit codes