Fixed critical error and removed redundancy