Improoving the code