changed error logging and return value for the better