fixed wrong error
better error handling and better error messages
merge