Added error catching, needs more robust workarounds for nil values