currently broken, but rearranging code