cleanup / more error checks / safety