fixed if 0
fixed null pointer exception