changed reference logick to be more accurate, cosmetics