updated to work a little better