Added a str check for python3 compatibility