Fixed wrong code checking logic.