Finally compiles correctly... not sure if it works...