updated and commented Brain lib