Fixed Reference and moved logic back in