Fixed return code bug