add some error checks and defaults