Edited add function, look at line 30 to fix null pointer exception