Fix a bug in home() method and clean up the code a bit
Fix a bug in home() method and clean up the code a bit