fixing bug and adding log