added check function & comments, fixed types