Fixed null pointer exception and changed tabs to spaces