fixing output
fixing error handling