Simplified the code