Simplified and added comments