added timeout parameter

should be working more correctly now