first compile attempt
this is working, but needs improvment