better output control, refactored status codes into constants