fixed nil reference