corrected #2 with precedence

need to finish #3