How to implement a reference checking system