Original file
Move to lib and fix for undefined variables