debugged first version of reference