Fixed the issue where function was not firing