Fixed potential bugs based on brinkman's feedback