restructured source to compile correctly