updated code a little