fixed bugs with fomulas, added comments