Fixed the faulty code