Bug fixed and all functions work correctly.