impoving the code a bit