fixed nil errors