Fixed the bug in order of outputs