Fixed error and removed useless code