Finalized fixing the bug