Added some error checking - actually compiles now