fixing fatal indexexception bug