Fixing null pointer exc