updated code a bit