improved the code :)