sorted out general references in an ugly way but it works