Fixing reference bug