diff --git a/getgauge/impl_loader.py b/getgauge/impl_loader.py
index <HASH>..<HASH> 100644
--- a/getgauge/impl_loader.py
+++ b/getgauge/impl_loader.py
@@ -2,7 +2,6 @@ import importlib
 import inspect
 import json
 import logging
-import py_compile
 import shutil
 import sys
 import traceback
@@ -76,6 +75,7 @@ def update_step_resgistry_with_class(instance, file_path):
         if info.impl.__name__ in class_methods:
             info.instance = instance
 
+
 def _get_version():
     json_data = open(PLUGIN_JSON).read()
     data = json.loads(json_data)
diff --git a/getgauge/registry.py b/getgauge/registry.py
index <HASH>..<HASH> 100644
--- a/getgauge/registry.py
+++ b/getgauge/registry.py
@@ -114,7 +114,8 @@ class Registry(object):
             return _filter_hooks(tags, getattr(self, '__{}'.format(hook)))
 
         def add(self, func=None, tags=None, file_name=""):
-            file_name = inspect.getabsfile(func) if file_name is None else file_name
+            if not isinstance(func, str):
+                file_name = inspect.getsourcefile(func)
             getattr(self, '__{}'.format(hook)).append(
                 HookInfo(tags, func, file_name))
Fixed file name issue for class hooks #<I>