simplified the code