Added null check, formatting