fixing bugs in compile error and gpu throws exception