cleanup

add type guards