fixing bug when called with three arguments