housekeeping
adding some fail-proof checks