Commented all code and added thread safety argument