Fixed null pointer excetpion