Added null check in MainActivity