updated code a little to make it work.