improve the code a bit more