resolved bugs, add comments and todo