Sorry I forgot an & in my code. The return for output should be a reference to an object and not an object itself. Code has been updated. Btw in the future you may want to include the errors instead of just saying you have errors.