modified for fixing bug