fixed nil bug