Fix code formatting.
Move sample function to lib.py