Ward commented database calls and added two if statements to avoid null-pointer-exceptions