better checks, and added documentation