diff --git a/go/logic/server.go b/go/logic/server.go
index 2ef270355..1f9252f25 100644
--- a/go/logic/server.go
+++ b/go/logic/server.go
@@ -52,10 +52,6 @@ func NewServer(migrationContext *base.MigrationContext, hooksExecutor *HooksExec
 }
 
 func (this *Server) runCPUProfile(args string) (string, error) {
-	if atomic.LoadInt64(&this.isCPUProfiling) > 0 {
-		return "", ErrCPUProfilingInProgress
-	}
-
 	duration := defaultCPUProfileDuration
 
 	var err error
@@ -78,6 +74,9 @@ func (this *Server) runCPUProfile(args string) (string, error) {
 		}
 	}
 
+	if atomic.LoadInt64(&this.isCPUProfiling) > 0 {
+		return "", ErrCPUProfilingInProgress
+	}
 	atomic.StoreInt64(&this.isCPUProfiling, 1)
 	defer atomic.StoreInt64(&this.isCPUProfiling, 0)
 
diff --git a/go/logic/server_test.go b/go/logic/server_test.go
index 8f05d9442..3cb9fcb1a 100644
--- a/go/logic/server_test.go
+++ b/go/logic/server_test.go
@@ -2,7 +2,6 @@ package logic
 
 import (
 	"encoding/base64"
-	"fmt"
 	"testing"
 	"time"
 
@@ -44,8 +43,6 @@ func TestServerRunCPUProfile(t *testing.T) {
 		tests.S(t).ExpectNil(err)
 		tests.S(t).ExpectNotEquals(profile, "")
 
-		fmt.Println(profile)
-
 		data, err := base64.StdEncoding.DecodeString(profile)
 		tests.S(t).ExpectNil(err)
 		tests.S(t).ExpectEquals(len(data), 106)