Resolved Errors and clean the code