Done with the logic, some errors need to be corrected