Simplified the code
Updated example