Completed the code and updated with more documentation