fixed an error message output and adding some changes that escaped the last commit