fixed bug with references