code after fixing the issues