Organized code. Object return now can use the poll function
part 2 of previous commit
updated test