Added call to database insert function

Also did some variable casting to match the function signiture