fixed seg fault, add() method still riddled with bugs