updated the code a bit